import pygame
from pygame.sprite import Sprite

class Alien(Sprite):
    def  __init__(self, ai_game):
        super().__init__()
        self.screen = ai_game.screen
        self.settings = ai_game.settings
        self.image = pygame.image.load('.\images\\alien.bmp')
        # 重置alien图片大小
        self.image = pygame.transform.scale(self.image, (self.settings.alien_transform_width, self.settings.alien_transform_height))
        self.rect = self.image.get_rect()
        self.rect.x = self.rect.width
        self.rect.y = self.rect.height
        self.x = float(self.rect.x)
        self.y = float(self.rect.y)

    # 检查外星人是否到屏幕底部边缘
    def check_edges(self):
        screen_rect = self.screen.get_rect()
        return self.rect.bottom >= screen_rect.bottom
        

    # 向下移动外星人
    def update(self):
        self.y += self.settings.fleet_drop_speed
        self.rect.y = self.y
    
